package com.bckj.freshnow.order.trade.execution.create;

import com.bckj.fastboot.core.execution.Execution;
import com.bckj.fastboot.core.execution.ExecutionContext;
import com.bckj.freshnow.common.gen.IdGenerator;
import com.bckj.freshnow.order.entity.TradeParentOrder;
import com.bckj.freshnow.order.trade.fsm.TradeOrderContext;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CreateTradeOrderInitExecution implements Execution {

    @Override
    public void execute(ExecutionContext context) {
        var ctx = (TradeOrderContext) context;
        TradeParentOrder parentOrder = new TradeParentOrder();
        setParentOrder(parentOrder);
        ctx.setParentOrder(parentOrder);
    }

    private void setParentOrder(TradeParentOrder parentOrder) {
        parentOrder.setParentOrderNo(IdGenerator.generateOrderNo(""));
    }
}
